/*
  ID: nemokin1
  PROG: clocks
  LANG: C++
*/
//  using: truncate dfs, seems use too much time

#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <fstream>

using namespace std;
 
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define FORD(i,a,b) for(int i=(a);i>=b;--i)
#define FOREACH(it,c) for(typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define ALL(c) (c).begin(),(c).end()
 
#define debug(x) cerr<< #x << " = " << (x) << "\n";
#define debugv(v) cerr << #v << " = "; FOREACH(it,v) cerr << *it <<","; cerr << "\n";
#define SIZE(a)  (int(a.size()))
 
template<typename T> inline void checkMax(T& a, T b) {if (b>a) a=b;}
template<typename T> inline void checkMin(T& a, T b) {if (b<a) a=b;}
 
typedef long long LL;
typedef vector<int> VI;
typedef vector<string> VS;
typedef long double ld;
const int INF = 1000000000;

vector<string> op;


VI vi;
VI ret;
bool goon = true;

void rotate(int p)
{
    for(int i = 0; i < op[p].size(); i++){
	if(vi[op[p][i]-'A'] != 12) vi[op[p][i]-'A']+=3;
	else vi[op[p][i]-'A'] = 3;
    }
}

bool alldone()
{
    for(int i = 0; i < 9; i++){
	if(vi[i] != 12) return false;
    }
    return true;
}

void dfs(int depth, int start)
{
    if(depth == 0) {return;}
    VI temp = vi;
    for(int i = start; i < 9; i++){
	int cnt = 0;
	for(int tt = 0; tt < ret.size(); tt++)
	    if(ret[tt] == i) cnt++;
	if(cnt >= 3) continue;
	vi = temp;
	rotate(i);
	ret.push_back(i);
	if(alldone()){
	    for(int i = 0; i < ret.size()-1; i++){
		cout << ret[i]+1 << " ";
	    }
	    cout << ret[ret.size()-1]+1 << endl;
	    goon = false;
	    return;
	}
	else{
	    dfs(depth-1, i);
	}
	//if(goon == false) return;
	vi = temp;
	ret.pop_back();
    }
}

	
int main() {
    //freopen("clocks.in","r",stdin);freopen("clocks.out","w",stdout);
    op.push_back("ABDE");
    op.push_back("ABC");
    op.push_back("BCEF");
    op.push_back("ADG");
    op.push_back("BDEFH");
    op.push_back("CFI");
    op.push_back("DEGH");
    op.push_back("GHI");
    op.push_back("EFHI");
    
    for (int i = 0; i < 9; ++i)
    {
	int m;
	cin >> m;
	vi.push_back(m);
    }
    //for(int i = 1; i < 20; i++){
    //if(!goon) break;
    //ret.clear();
    dfs(30,0);
//    }
    exit(0);
}
    
